//
//
//#include <cassert>
//12.26
//
//
#include <iostream>
#include <string>
using namespace std;

int main()
{

	string arr[5];
	for (int i = 0; i < 5; i++)
		cin >> arr[i];

	int ans = 0;
	for (int i = 0; i < 5; i++)
	{
		// 2 0 2 1
		if (arr[i][0] == arr[i][2]
			&& (arr[i][3]-'0' == (arr[i][1]-'0' + 1)%10))
			ans++;
	}
	cout << ans << endl;

	return 0;
}